package edu.sctu.wangxiaoqiang.day20150609;



import edu.sctu.wangxiaoqiang.day20150609.appbean.PeopleAppbean;
import edu.sctu.wangxiaoqiang.day20150609.data.SetPeopleData;
import edu.sctu.wangxiaoqiang.day20150609.data.SetTrianData;
import edu.sctu.wangxiaoqiang.day20150609.util.BaoGuoDeth;
import edu.sctu.wangxiaoqiang.day20150609.util.CardDeth;

import java.util.Iterator;
import java.util.List;

/**
 * Created by user25 on 2015/6/9.
 */
public class DtialUtil {

    private String weijin = "dfgsdg";
    private SetPeopleData setPeopleData = new SetPeopleData();
    private SetTrianData setTrianData = new SetTrianData();

    public DtialUtil(){}

    public void getPeople(){
        List list = this.setPeopleData.setPeopleData();
        Iterator var3 = list.iterator();

        while(var3.hasNext()) {
            PeopleAppbean people = (PeopleAppbean)var3.next();
            if(people.isIs_card()) {
                String problem = this.chaBaoGuo(people);
                System.out.println(problem);
                if(problem.contains("无")) {
                    this.kouPrice(people);
                }
            }
        }
    }

    public String chaBaoGuo(PeopleAppbean people) {
        BaoGuoDeth baoguodeth = new BaoGuoDeth(people, this.weijin);
        return baoguodeth.chaBaoGuo()?"包裹有问题":this.chaWater(people);
    }

    public String chaWater(PeopleAppbean people) {
        BaoGuoDeth baoguodeth = new BaoGuoDeth(people, this.weijin);
        if(baoguodeth.chaWater()) {
            return "水有问题";
        } else {
            this.ifPrice(people);
            return "都无问题";
        }
    }

    public void ifPrice(PeopleAppbean peopleAppbean) {
        if(peopleAppbean.getPrice() > 2) {
            System.out.println("进站");
        } else {
            (new CardDeth()).setPrice(10, peopleAppbean);
            System.out.println("充值完成");
            this.ifPrice(peopleAppbean);
        }
    }

    public void kouPrice(PeopleAppbean peopleAppbean) {
        CardDeth cardDeth = new CardDeth(this.setTrianData.setHashMapData());
        if(peopleAppbean.getPrice() >= cardDeth.getPrice(peopleAppbean.getStart_station(), peopleAppbean.getEnd_station())) {
            System.out.println("出站,余额为:" + (peopleAppbean.getPrice() - cardDeth.getPrice(peopleAppbean.getStart_station(), peopleAppbean.getEnd_station())));
        } else {
            cardDeth.setPrice(10, peopleAppbean);
            System.out.println("充值成功");
            this.kouPrice(peopleAppbean);
        }

    }

}
